#!/bin/csh -f
# Revives file from Attic
# $Id$

if ( ! -d CVS ) then
    echo "No Subversion support yet"
    exit 1
endif

set endofline='$'

foreach fil ( $* )

    set revfrom=`cvs log $fil | grep 'head:' | awk '{print $2}'`
    set lastnr=`echo $revfrom|sed 's/\./ /g'|awk '{print $NF}'`
    @ targetnr = $lastnr - 1
    set revto=`echo ${revfrom}|sed "s/${lastnr}${endofline}/${targetnr}/"`

    echo ""
    echo "About to issue command:"
    echo "cvs update -j $revfrom -j $revto $fil"
    echo -n "OK? "; set inp=$<
    if ( "$inp" == "y" || "$inp" == "Y" ) then
	cvs update -j $revfrom -j $revto $fil
    else
	echo "$fil not restored"
    endif

end

